﻿using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace UdpApplication{
    public partial class MainWindow : Form{
        private void SW_DoWork(object sender, DoWorkEventArgs e){
            ServerBuilder.Build(serverStatus);
        }
        
        private void CW_DoWork(object sender, DoWorkEventArgs e){
            ClientBuilder.Build(clientStatus,content.Text);
        }
        
        private void Send_Click(object sender,EventArgs args){
            if (!clientWork.IsBusy) {
                clientWork.RunWorkerAsync();
            }
        }
        
        private void Start_Click(object sender,EventArgs args){
            if (!serverWork.IsBusy) {
                serverWork.RunWorkerAsync();
            }
        }
        private void AddEvent(){
            start.Click += Start_Click;
            serverWork.DoWork += SW_DoWork;
            send.Click += Send_Click;
            clientWork.DoWork += CW_DoWork;
        }
        
        
        
        public MainWindow(){
            InitializeComponent();
            AddEvent();
        }
    }
}